<!DOCTYPE html>
<!--

Copyright 2016 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<html>
<head>
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Sahitya|Share+Tech+Mono|Yanone+Kaffeesatz" rel="stylesheet">
<style>
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Yanone Kaffeesatz";
  color: white;
  font-size: 18px;
  letter-spacing: 1.5px;
  line-height: 1.5em;
}
* {
  box-sizing: border-box;
}

h1, h2 {
  font-family: "Sahitya";
  text-shadow: 0 0 4px white, 3px 3px 1px black;
  line-height: 1.2em;
}
h1 {
  font-size: 4em;
}
h2 {
  font-size: 2.5em;
}
code, pre {
  font-family: "Share Tech Mono";
  font-size: 0.8em;
}
.scene {
  height: 150vh;
  padding: 5vh 10vw;
}

.parallax {
  background-size: cover;
  box-sizing: border-box;
  width: 100%;
  height: 130vh;
  /* Since the parallax elements still consume space, we set the margin to undo
     the height of this parallax element making it essentially consume 0 space.
  */
  margin-bottom: -130vh;
}

.header {
  height: 70vh;
}
.parallax.header {
  margin-bottom: -70vh;
}

p {
  color: white;
  margin: 1em 0;
  z-index: 1;
  position: relative;
}

.viewport {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  -webkit-overflow-scrolling: touch;
}
.woods:not(.header),
.sunset:not(.header) {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.sunset:not(.header) {
  align-items: flex-end;
}
.solid {
  z-index: 1;
  position: relative;
  height: 70vh;
  font-size: 1.5em;
  line-height: 1.5em;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

.solid.star {
  background-image: linear-gradient(hsla(240, 90%, 8%, 1) 0%, 99%, hsla(217,24%,71%,0) 100%);
  box-shadow: -10px -10px 20px hsl(240, 90%, 8%);
}
.solid.woods {
  background-color: hsl(195, 16%, 49%);
  box-shadow: -10px -10px 20px hsl(195, 16%, 49%);
}
a, a:link, a:active, a:hover, a:visited {
  color: hsl(240, 100%, 90%);
  display: flex;
  align-items: flex-end;
}

</style>
<script src="scripts/parallax.js"></script>
<script>
  document.addEventListener('DOMContentLoaded', function() {
    initializeParallax(document.querySelector('.viewport'));
  });
</script>
</head>
<body>
    <div class="viewport">
    <div>
      <!-- Specifying a parallax rate of 0.3 will slide the image at that proportion of the scroll speed. -->
      <div class="parallax header" style="background-image: url('images/stars.jpg');" parallax="0.3"></div>
      <div class="scene header">
        <h1>Gazing into the stars&nbsp;&nbsp;🐱</h1>
        <h2>When cats use <code>requestIdleCallback</code></h2>
      </div>
      <div class="scene solid star">
        <p>
          What’s this? This is a parallax scroller. But not just yet another parallax scroller, it’s one that doesn’t rely on JavaScript for the animation, that works on both desktop and mobile and has 60fps while scrolling. This was a lot harder than we originally anticipated, so we wrote up what we did for you to read!
        </p>
        <p>
          <a href="https://developers.google.com/web/updates/2016/12/performant-parallaxing">
          <img src="images/screengrab.jpg" style="width: 10vw; float: left; margin-right: 2vw;">
          Read the article on developers.google.com!</a>
        </p>
      </div>
      <!-- When a rate isn't specified, it will be calculated such that the image always fills the space between the
           element before it and the next element with the "parallax-cover" attribute. -->
      <div class="parallax" style="background-image: url('images/sea.jpg');" parallax></div>
      <div class="scene woods">
        <h1>Gazing into the sea&nbsp;&nbsp;🐳</h1>
        <h2>Some people don’t have <code>class</code></h2>
      </div>
      <div class="scene solid woods" parallax-cover>
        <p>
          Lorem ipsum dolor sit amet, et natum mucius quo, nam zril offendit ei. Cu mea amet paulo consequat. Eam nonumy integre malorum ei. Fabulas feugait detracto cu usu. Ad brute moderatius sit, ne mel ullum saperet.
        </p>
        <p>
          Inermis petentium cotidieque sed cu. No duo alienum salutandi. Exerci evertitur vix ea, mei audire conclusionemque an. His nisl graece euismod ad.
        </p>
      </div>
      <!-- When a rate isn't specified and there is no subsequent element with the "parallax-cover" attribute the rate
           will be calculated such that the image slides until the end of the scrollable content. -->
      <div class="parallax" style="background-image: url('images/sunset.jpg');" parallax></div>
      <div class="scene sunset">
        <h1>Gazing into the sunset&nbsp;&nbsp;🌞</h1>
        <h2><code>!important</code> is not a performance primitive</h2>
      </div>
    </div>
  </div>
</body>
</html>
